<template>
  <div class="header-container">
    <div class="l-container">
      <el-button size="small" @click="handleCollapse">
        <component class="icons" :is="'menu'"></component>
      </el-button>
      <el-breadcrumb separator="/" class="breadcrumb">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item v-if="tagsStore.currentMenu" :to="{ path: tagsStore.currentMenu.path }">{{ tagsStore.currentMenu.label }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-container">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img :src="getImageUrl('user')" class="user" alt=""/>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>个人中心</el-dropdown-item>
            <el-dropdown-item @click="logout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup lang="ts">
//import { ref, computed } from 'vue'
import { userCollapseStore } from '@/store/collapse'
import {useImageUrl} from '@/assets/js/utils'
import {useRouter} from 'vue-router'
import routerNames from '@/router/routerNames'
import {useLogoutStore} from '@/store/logout'
import {useTagsStore} from '@/store/tags'

const {getImageUrl} = useImageUrl()

const {handleCollapse} = userCollapseStore()

const router = useRouter()

const { cleanStore } = useLogoutStore()

const logout = () => {
  cleanStore()
  router.push({name: routerNames.login})
}

const tagsStore = useTagsStore()

</script>

<style lang="less" scoped>
.header-container{
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: #333;

  .l-container{
    display: flex;
    align-items: center;
    .el-button{
      margin-right: 20px;
    }
  }

  .icons{
    width: 20px;
    height: 20px;
  }

  .r-container{
    .user{
      width: 40px;
      height: 40px;
      border-radius: 50%;
      cursor: pointer;
      outline: none;
      border: none;
    }
  }

  :deep(.breadcrumb span){
    color: #fff;
    cursor: pointer !important;
  }
}
</style>